{% extends "base.html" %}

{% block title %}编辑项目{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h4 class="mb-0">编辑项目</h4>
                </div>
                <div class="card-body">
                    <form method="post">
                        <div class="mb-3">
                            <label for="name" class="form-label">项目名称</label>
                            <input type="text" class="form-control" id="name" name="name" 
                                   value="{{ project.name }}" required>
                        </div>
                        <div class="mb-3">
                            <label for="project_code" class="form-label">项目编号</label>
                            <input type="text" class="form-control" id="project_code" 
                                   value="{{ project.project_code }}" readonly>
                            <small class="text-muted">项目编号不可修改</small>
                        </div>
                        <div class="mb-3">
                            <label for="project_type" class="form-label">项目类型</label>
                            <select class="form-select" id="project_type" name="project_type" required>
                                <option value="industrial" {% if project.project_type == 'industrial' %}selected{% endif %}>工业测控</option>
                                <option value="environmental" {% if project.project_type == 'environmental' %}selected{% endif %}>环境监测</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">项目规模</label>
                            <div class="row">
                                <div class="col-md-6">
                                    <input type="number" class="form-control" id="monitoring_points" 
                                           name="monitoring_points" placeholder="监测点数" 
                                           value="{{ project.scale.monitoring_points }}" required>
                                </div>
                                <div class="col-md-6">
                                    <input type="number" class="form-control" id="control_loops" 
                                           name="control_loops" placeholder="控制回路数量" 
                                           value="{{ project.scale.control_loops }}" required>
                                </div>
                            </div>
                        </div>
                        <div class="mb-3">
                            <label for="status" class="form-label">项目状态</label>
                            <select class="form-select" id="status" name="status" required>
                                <option value="draft" {% if project.status == 'draft' %}selected{% endif %}>草稿</option>
                                <option value="pending" {% if project.status == 'pending' %}selected{% endif %}>待审核</option>
                                {% if current_user.role == 'manager' %}
                                <option value="approved" {% if project.status == 'approved' %}selected{% endif %}>已批准</option>
                                <option value="rejected" {% if project.status == 'rejected' %}selected{% endif %}>已拒绝</option>
                                {% endif %}
                            </select>
                        </div>
                        <div class="text-end">
                            <a href="{{ url_for('main.project_detail', project_id=project.id) }}" 
                               class="btn btn-secondary">取消</a>
                            <button type="submit" class="btn btn-primary">保存修改</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 